package com.ihooyah;

import java.util.*;

/**
 * @author 李诚 【licheng@ihooyah.com】
 * @description
 * @create 2017-02-14 上午11:24
 **/
public class Test {
    public static void main(String[] args) {
        //Test test = new Test();
        //test.testMethod();


        Object a = new Object();
        Object b = new Object();
        Object c = new Object();
        MyTestThread pa = new MyTestThread("A", c, a);
        MyTestThread pb = new MyTestThread("B", a, b);
        MyTestThread pc = new MyTestThread("C", b, c);


        new Thread(pa).start();
        try {
            Thread.sleep(100);  //确保按顺序A、B、C执行
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(pb).start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(pc).start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    void testMethod() {
        ArrayList list = new ArrayList();
        list.add("a");
        list.add("b");

        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.printf(String.valueOf(iterator.next())+"\n");
        }


        LinkedList linkedList = new LinkedList();
        linkedList.add("c");
        linkedList.add("d");




        //堆栈
        Stack stack = new Stack();
        stack.push("e");
        stack.push("f");
        stack.push("g");
        System.out.printf(String.valueOf(stack.pop())+"\n");
        System.out.printf(String.valueOf(stack.peek())+"\n");

    }

}
